package net.projecteuler.programs.program0009;

import net.projecteuler.programs.TimeLogger;

/**
 * Special Pythagorean triplet
 *
 * A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
 *
 * a2 + b2 = c2
 * For example, 32 + 42 = 9 + 16 = 25 = 52.
 *
 * There exists exactly one Pythagorean triplet for which a + b + c = 1000.
 * Find the product abc.
 *
 * Created by zhaojjd on 2016/3/21.
 */
public class Program0009 {

    public int find(){
        int rst = 1;
        label: for(int i = 2; i < 500; i++){
            for(int j = 501 - i; j < 500; j++){
                int k = 1000 - i - j;
                if(i * i + j * j == k * k){
                    System.out.println("i,j,k = " + i + "," + j + "," + k);
                    rst = i*j*k;
                    break label;
                }
            }
        }
        return rst;
    }

    public static void main(String[] args) {
        Program0009 p = new Program0009();

        TimeLogger.tag();
        System.out.println("p.find() = " + p.find());
        TimeLogger.print();
    }

}
